package TestDemo;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2024-06-06
 * Time: 14:01
 */
class Animal {
    public String name;
    public int age;
    public String color;

    public Animal(){

    }

    public Animal(String name){
        this.name = name;
    }

    public Animal(int age){
        this.age = age;
    }

    public Animal(String name,String color){
        this.name = name;
        this.color = color;
    }
    public void eat(){
        System.out.println(name + "正在吃粮");
    }

    public void swap(){
        System.out.println(name + "正在摇尾巴");
    }
}

class Dog extends Animal {
    {
        name = "初一";
        age = 2;
    }
    public Dog(){
        super();
    }

    public Dog(String name){
        super(name);
    }

    public Dog(int age){
        super(age);
        System.out.println("年龄：" + age);
    }

    public Dog(String name,String color){
        super(name,color);
        System.out.println("姓名：" + name + " 颜色：" + color);
    }

    public void wangWang(){
        System.out.println(name + "正在吠叫");
    }
}

class Bird extends  Animal{
    {
        name = "小鸟";
        age = 1;
    }
    public Bird(){
        super();
    }

    public Bird(String name){
        super(name);
    }

    public Bird(int age){
        super(age);
        System.out.println("年龄：" + age);
    }

    public Bird(String name,String color){
        super(name,color);
        System.out.println("姓名：" + name + " 颜色：" + color);
    }

    public void fly(){
        System.out.println(name + "正在飞翔");
    }
}

public class Test {
    public static Animal func(){
        return new Dog("初一","黑色");
    }

    public static Animal func1(){
        return new Bird("初二","白色");
    }
    public static void main(String[] args) {
        Dog dog = new Dog();
        Bird bird = new Bird();
        Animal animal1 = func();
        Animal animal2 = func1();
    }
}
